package com.ibm.cloud.redis.connection;

public class RedisSentinelSliceResolver {
	public int getSliceNumber(String factor) {
//		int crc16 = CRC16Utils.getCrc16(factor.getBytes());
		int crc16 = CRC16Util.calcCrc16(factor.getBytes());
		int res = (crc16 + factor.hashCode()) % 16;
		if (res < 0)
			res = -res;
		return res + 1;
	}

	public int getSliceNumber1(String factor) {
//		int crc16 = CRC16Utils.getCrc16(factor.getBytes());
		int crc16 = CRC16Util.calcCrc16(factor.getBytes());
		int res = crc16 % 16;
		return res + 1;
	}

	public int getGoupNumber(int sliceNumber) {
		return (sliceNumber - 1) / 8 + 1;
	}
}
